package org.neurone.action.userspace;

import org.neurone.action.BaseActionSupport;
import org.neurone.context.MessageConst;
import org.neurone.domain.UserInfo;
import org.neurone.userspace.userinfo.UserFace;
import org.neurone.userspace.userinfo.impl.UserFaceLocal;
import org.neurone.userspace.userinfo.impl.UserFaceLocalFactory;

public class UserInfoViewAction extends BaseActionSupport {
	private Long userid;
	private UserFaceLocalFactory userFaceFactory;
	private UserInfo userInfo;
	
	public UserFaceLocalFactory getUserFaceFactory() {
		return userFaceFactory;
	}
	public void setUserFaceFactory(UserFaceLocalFactory userFaceFactory) {
		this.userFaceFactory = userFaceFactory;
	}
	
	public Long getUserid() {
		return userid;
	}
	public void setUserid(Long userid) {
		this.userid = userid;
	}
	public UserInfo getUserInfo() {
		return userInfo;
	}
	public void setUserInfo(UserInfo userInfo) {
		this.userInfo = userInfo;
	}
	public String viewUser()
	{
		UserFaceLocal tuser = userFaceFactory.getNewUserFace(this.userid);
		if(tuser.isPersistentAvailable())
		{
			this.userInfo = tuser;
			return success();
		}
		else
		{
			this.addActionError(MessageConst.NO_SUCH_USER);
			return ERROR;
		}
		
	}
}
